package hft_suttgart.pvc;

import java.util.List;

import com.example.hft_suttgart.swp2.R;

import database.DatabaseHandler;
import database.Player;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class Db_Executer extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_db_);
		
		DatabaseHandler db = new DatabaseHandler(this);
		 
	    /**
	     * CRUD Operations
	     * */
	    // Inserting players
		Log.d("Insert: ", "Inserting ..");
	    db.addPlayer(new Player("Ayoub", "123"));
	    db.addPlayer(new Player("Boris", "213"));
	    db.addPlayer(new Player("Steffan", "321"));
	    db.addPlayer(new Player("Benjamin", "132"));
	    Log.d("Reading: ", "Reading all contacts..");
        List<Player> players = db.getAllPlayers();      
 
        for (Player player : players) {
            String log = "Id: "+player.getId()+" ,Name: " + player.getName() + " ,Password: "
                    + player.getPassword();
                // Writing players to log
        Log.d("Name: ", log);
	}
     }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.db_, menu);
		return true;
	}

}
